package com.tgh.utils;

import java.io.Serializable;

public class Vector2f implements Cloneable,Serializable{
    private static final long serialVersionUID = 6519958161170859681L;
    
    public Vector2f(float[] array, int offset) {
		this.x = array[0 + offset];
		this.y = array[1 + offset];
	}

	public Vector2f(float initX, float initY) {
		x = initX;
		y = initY;
	}

	public Vector2f() {
	}

	public void copy(float x, float y) {
		this.x = x;
		this.y = y;
	}

	public void copy(float[] array, int offset) {
		this.x = array[0 + offset];
		this.y = array[1 + offset];
	}
	
	
	@Override
	public Vector2f clone(){
		Vector2f vector2f=null;
		try {
			vector2f=(Vector2f) super.clone();
		} catch (CloneNotSupportedException e) {}
		return vector2f;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Float.floatToIntBits(x);
		result = prime * result + Float.floatToIntBits(y);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Vector2f other = (Vector2f) obj;
		if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
			return false;
		if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "(" + x + ", " + y + ")";
	}

	public float x;
	public float y;
}
